﻿/* 
 *  <copyright file="Camera2DCmp.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SobrietyEngine.Components.Camera
{
    public class Camera2DCmp: BaseCamera, IComponent, ICamera
    {
        public Camera2DCmp()
            : base()
        {
        }

        //for code base creation
        public Camera2DCmp(Viewport _viewport, Matrix _viewScale)
            : base()
        {
            Viewport = _viewport;
            ViewportScale = _viewScale;          
        }

        public override Boolean InitComponent()
        {
            return base.InitComponent();
        }

        override public Type[] SupportedInterfaces()
        {
            return new Type[] { typeof(ICamera) };
        }

        public override Matrix GetViewMatrix()
        {
            //gets world to screen transformation
            return Matrix.CreateTranslation(new Vector3(-1 * Lens.X, -1 * Lens.Y, 0)) * ViewportScale;
        }
    }
}